// 全局剧本搜索筛选条件
export default{
	data(){
		return {
			selectList:[],
			show:false,
			timer:""
		}
	}, 
	onLoad(){
		this.$store.dispatch('getClassify').then(res=>{
			this.selectList = res.filter(val=>['剧本类别','剧本背景','剧本题材','发行方式'].includes(val.label)).map(val=>{
				this.$set(val,'open',false)
				this.$set(val,'checked',[])
				return val;
			});
		})
	},
	methods:{
		getconfirm(){
			if(this.timer){
				clearTimeout(this.timer);
				this.timer = null;
			}
			this.timer = setTimeout(this.setDown,300)
		},
		setDown(){
			this.downCallback()
		},
		//侧边栏选中
		selectItem(item,val){
			const checked = item.checked.includes(val.id) ? [] : [val.id];
			this.$set(item,'checked',checked)
		},
		//重置
		resetBtn(){
			this.selectList.map(val=>{
				val.checked = [];
				return val;
			})
			this.category()
		},
		//获取选中的分类参数
		category(){
			this.form.categoryIds = [];
			this.form.peopleDesc = '';
			this.selectList.forEach(val=>{
				if(val.label==='人数'){
					const person = val.children.find(item=>val.checked.includes(item.id));
					if(person) this.form.peopleDesc = person.label;
				}else{
					this.form.categoryIds = [...val.checked,...this.form.categoryIds]
				}
			})
			this.show = false;
			this.downCallback()
		},
	}
}